home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_100 / 187_01 / chgattr.c < prev    next >
C/C++ Source or Header  |  1986-02-19  |  2KB  |  47 lines

  1. /*@*****************************************************/
  2. /*@                                                    */
  3. /*@ chgattr - get or set attribute on named file.      */
  4. /*@                                                    */
  5. /*@   Usage:    chgattr(getset, path, attr);           */
  6. /*@       where getset is 'S' or anything else.  If    */
  7. /*@                it is 'S', the file attribute is    */
  8. /*@                changed to attr.  Otherwise the     */
  9. /*@                current file attribute is returned  */
  10. /*@                in attr.                            */
  11. /*@                                                    */
  12. /*@       returns zero if successful, non-zero otherwise.*/
  13. /*@       1 => invalid function (from DOS).            */
  14. /*@       3 => path not found (from DOS).              */
  15. /*@       5 => access denied (from DOS).               */
  16. /*@                                                    */
  17. /*@*****************************************************/
  18.  
  19.  
  20. extern unsigned _rax, _rbx, _rcx, _rdx, _rsi, _rdi, _res, _rds;
  21. extern char _carryf, _zerof;
  22.  
  23.  
  24. int chgattr(getset, path, attr)
  25. char getset, *path;
  26. int *attr;
  27. {
  28.     if (getset == 'S') {
  29.         _rcx = *attr;
  30.         _rax = 0x4301;        /* DOS change attributes function */
  31.     }
  32.     else
  33.         _rax = 0x4300;        /* DOS get attributes function */
  34.  
  35.     _rds = _showds();        /* segment of path */    
  36.     _rdx = path;            /* offset of path */
  37.  
  38.     _doint(0x21);            /* call DOS */
  39.  
  40.     if (!_carryf)            /* error ? */
  41.         _rax = 0;            /* ..no, clear reg */
  42.  
  43.     if (_rax == 0)
  44.         *attr = _rcx;
  45.     return(_rax);
  46. }        
  47.